package cn.bugio.task02;

import cn.bugio.task02.bean.Bean1;
import cn.bugio.task02.bean.Bean2;
import cn.bugio.task02.bean.Bean3;
import cn.bugio.task02.bean.User;
import cn.bugio.task02.controller.UserController;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App
{
    public static void main( String[] args ) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext02.xml");
        Bean1 bean1 = (Bean1) applicationContext.getBean("bean1");
        System.out.println(bean1); //Bean1{name='test1'}
        Bean2 bean2 = (Bean2) applicationContext.getBean("bean2");
        System.out.println(bean2); //Bean2{name='test2'}
        Bean3 bean3 = (Bean3) applicationContext.getBean("bean3");
        System.out.println(bean3);
        //bean3 实例化
        //Bean1{name='test1'}
        //Bean2{name='test2'}
        //Bean3{name='test3'}
        User user1 = (User) applicationContext.getBean("user1");
        System.out.println(user1); //User{username='test4-username', password=123456, list=[test4-v1, test4-v2]}

        User user2 = (User) applicationContext.getBean("user2");
        System.out.println(user2); //User{username='test5-username', password=123456, list=[test5-v1, test5-v2]}

        UserController userController = (UserController) applicationContext.getBean("userController");
        userController.save();
        //dao save....
        //service save ....
        //controller save ...
    }
}
